package com.example.photography.fragment.community;

import android.text.TextUtils;
import android.widget.ListView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.photography.R;
import com.example.photography.adapter.community.Com_AppointAdapter;
import com.example.photography.bean.Appoint_OrderBean;
import com.example.photography.common.AppNetConfig;
import com.example.photography.common.BaseFragment;
import com.loopj.android.http.RequestParams;

import java.util.List;

import butterknife.BindView;

public class Appoint_Recently extends BaseFragment {
    private List<Appoint_OrderBean> appoint_orderBeans;
    @BindView(R.id.lv_appoint)
    ListView lvAppoint;

    @Override
    protected RequestParams getParams() {
        return null;
    }

    @Override
    protected String getUrl() {
        return AppNetConfig.order_appoint_unreacted;
    }

    @Override
    protected void initData(String content) {
        if (TextUtils.isEmpty(content)) {//数据为空
            return;
        }
        JSONObject jsonObject = JSON.parseObject(content);
        int status = jsonObject.getInteger("status");
        if (status == 202) {
            String data = jsonObject.getString("data");
            //封装转json数据
            appoint_orderBeans = JSONObject.parseArray(data, Appoint_OrderBean.class);
            initView();
        } else {
            // TODO: 2021/5/2 加没数据的判断
        }
    }

    private void initView() {
        Com_AppointAdapter com_appointAdapter = new Com_AppointAdapter(appoint_orderBeans, getActivity());
        lvAppoint.setAdapter(com_appointAdapter);
    }


    @Override
    public int getLayoutId() {
        return R.layout.fragment_appoint;
    }
}
